 (function(){
	 /**@description 根据标签名称生成JQDom
	 * @param tag {String}  标签名
	 * @param css {String}  样式名称
	 * @param id {id} dom id
	 * @param type {id} dom type
	 * @return {JQDom} 
	 */
	 $.create = function (tag,css,id,type) {
		 var dom = $(document.createElement(tag));
		 css && dom.addClass(css);
		 id && dom.id(id);
		 type && dom.attr("type",type);
	     return dom;
	}
	$.getEventTarget = function(e,fnCheck){
		var target = $(e.target || e.srcElement);
		if(fnCheck && !fnCheck(target))
		{
			var pTarget = target.parent();
			while(pTarget.length && e.delegateTarget != pTarget[0])
			{
				if(fnCheck(pTarget))
					return pTarget;
				else
					pTarget = pTarget.parent();
			}
		}
		return target
	}
	 /**@description 获取对象id或者设置id
	 * @param id {String}  id
	 * @return {JQDom/String} 
	 */   
	$.fn.id = function (id) {
	    if (id !== void 0) {
	        this.attr('id', id);
	    return this;
	}
	else
	    return this.attr('id');
	}
	/** 获取正确的position，修正相对位置滚动时不正常的位置计算
	 */
	$.fn.fixedPosition = function(){
		var dom = this[0];
		return  {top:dom.offsetTop,left:dom.offsetLeft};
	}
	
	/** 获取正确的position，修正相对位置滚动时不正常的位置计算
	 */
	$.fn.getOffsetInf = function(){
		var offset = this.offset();
			offset.height = this.outerHeight();
			offset.width = this.outerWidth();
			offset.right = offset.width + offset.left;
			offset.bottom = offset.height + offset.top;
		return offset;
	}
	/**
	 * 生成一个guid
	 * @param length 生成的guid前缀
	 * @paeam prefix guid前缀
	 */
	$.newGuid=function(prefix,length){
	 	return  (prefix || "") + Math.floor(Math.random()*Math.pow(10,length || 8));
	}
	
	/**@description 设置/获取，以data方式的保持的value
	 * @param value {String}  值
	 * @return {JQDom/String} 
	 */
	$.fn.dataValue = function (value) {
	    if (value !== void 0) {
	        this.data('value', value);
	        return this;
	    }
	    else
	    {
	    	var type = this.attr('valueType'),value = this.data('value');
	    	if(type == 'array')
	    		return value ? value.split(Ccay.Config.Format.valueSplit) : null;

	    	return value || '';
	    }
	}
	
	/**@description 设置/获取对象的value，兼容dataValue
	 * @return {String} 
	 */
	$.fn.getValue = function () {
		var value= this.data('value');
	    return value== null ? this.val() : value;
	}
	
	$.fn.cacheSet = function(op,setName){
		var set = op[setName];
		delete op[setName];
		return this.data(setName,set);
	}
	$.fn.isVisiable = function(){
		return this.css('display') !== 'none' && this.length && this[0].offsetWidth > 0 && this[0].offsetHeight > 0;
	}
	
	/**@description 弹出层方法，默认在caller的下方弹出popup
	 * @param caller {JQDom}  请求对象
	 * @param popup {JQDom}  弹出层对象
	 * @param css {Json}  样式设置对应的偏移量，{left:0,top:0}
	 * @return {JQDom} pupup
	 */
	Ccay.UI.popup = function (caller, popuper, css,isShow,offset, container,auto) {
		//debugger;
		popuper = $(popuper);
	    if (!popuper.hasClass('ccay-popup'))
	    	popuper.addClass('ccay-popup');
	    caller = $(caller);
	    if(!caller.length)
	    	return;
	    var position;
	    //对于域内元素的相对offset
	    if(offset == "fixed")
	    {
	    	position = caller.fixedPosition();
	    }
	    else if(offset == "position")
	    {
	    	position = caller.position();
	    	var dialog = caller.parents(".ccay-dialog-body:first");
	    	if(dialog.length > 0)
	    	{
	    		position.left += dialog.scrollLeft();
	    		position.top += dialog.scrollTop();
	    	}
	    }
	    else if(offset === true || popuper.hasClass("calendar"))
	    {
	    	if(auto)
	    	{
		    	popNum++;
		    	popuper.data("_popnum",true).show(); 
		    	Ccay.UI.checkPopuperPosition(caller,popuper);
		    	caller.parents(".ccay-popup").addClass("ccay-popup-lock");
		    	return;
	    	}
	    	else
	    		position = caller.offset();
	    }
	    else if(caller.parent().hasClass('gt-editor-container')){
	    	var dialog = caller.parents(".ccay-dialog:first");
	    	if(dialog.length > 0)
	    	{
	    		var dialogPosition = dialog.position();
	    		position = caller.offset();
	    		position.left -= dialogPosition.left;
	    		position.top -= dialogPosition.top;
	    	}
	    	else
	    		position = caller.offset();
	    }
	    else if(caller.parents(".ccay-dialog:first").length > 0){
	    	position = caller.fixedPosition();
	    }
	    else{
	    	position = caller.position();
	    }
	    position || (position = {left:0,top:0});
	    
	    if(css)
	    {
	    	if(css.left)
		    	position.left = css.left + position.left > 0 ? css.left + position.left : 0;
		    if(css.top)
		    	position.top = css.top + position.top > 0 ? css.top + position.top : 0;
	    }
	    
	    popuper.css(position);
	
	    if(isShow !== false)
	    {
	    	popuper.show();
	    	caller.parents(".ccay-popup").addClass("ccay-popup-lock");
	    }
	    return popuper;
	}
	//弹出层计数器
	var popNum = 0;
	//绑定主内容区域的中间关闭弹出层(子元素)事件
	$(document.body).bind("mousewheel",function(){
		var popDiv = Ccay.Page.getContentPanel().children("#popupPanel").children(".ccay-popup:visible");
		if(popNum){
			popDiv.filter(":not(.ccay-popup-lock)").each(function(){
				Ccay.UI.popupClose($(this));
			});
			popNum = popDiv.filter(':visible').length;
		}
		// 日历
		$("#ccay_calendar_div:visible").each(function(){
			if( !$("#timeZone_calendar_ddl:visible").length ){
				Ccay.UI.popupClose($(this));
			}
		});
	})
	Ccay.UI.getPopupPanel = function(){
		var panel = $('#popupPanel');
		if(panel.length)
			return panel;
		return $.create("div",null,"popupPanel").appendTo(Ccay.Page.getContentPanel());
	}
	/**@description 注册弹出层的关闭事件
	 */
	Ccay.UI.bindPopupClose = function(input,popuper,delay){
		input.blur(function(e){
			//popuper.removeData('_open');
			//Ccay.Core.log("blur");
//			setTimeout(function(){
				//Ccay.Core.log("checkblur : " + popuper.data('_open'));
				if(!popuper.data('_open'))
				{
					//Ccay.Core.log(11);
					//Ccay.Core.log(["blur -- ","open:" + popuper.data('_open'),"; inpop:" + popuper.data('_inpop')]);
					Ccay.UI.popupClose(popuper);
					if(popuper.attr("id") == "timeZone_calendar_ddl"){
						//如果是日期控件的时区选择，则把日期控件一起关闭
						Ccay.UI.popupClose($("#ccay_calendar_div"));
					}
				}
//			},delay || 200);
			
		})
//		.focus(function(){
//			//Ccay.Core.log("focus");
//			popuper.data('_open',true).data('_callInput',input);
//		});

		if(!popuper.data("_popupBinded"))
		{
			popuper.data("_popupBinded",true);
			this.bindPopupHover(popuper,function(popuper){
				popuper.data('_active',true);
			},
			function(popuper){
				popuper.data('_active',null);
			});
			
			popuper.bind('focusin',function(){
				//Ccay.Core.log("focusin");
				$(this).data('_open',true);
			})
			.focusout(function(){
				//Ccay.Core.log("focusout");
				setTimeout(function(){
					popuper.data('_open',null);
					if(!popuper.data('_active') && !input.is(":focus"))
					{
						popuper.data('_active',null);
						Ccay.UI.popupClose(popuper);
						Ccay.UI.popupClose($("#ccay_calendar_div"));
					}
					
				},delay || 100);
			})
		}
		
		
	}
	/**@description 关闭弹出层的*/
	Ccay.UI.popupClose = function(popuper,isClose){
		
		if(isClose || !popuper.data('_inpop'))
		{
			
//			Ccay.Core.log("close : " + (popNum - 1));
//			popNum > 0 && popuper.data("_popnum") && popNum--;
			var caller, callerId = popuper.data("callerId");
			if(callerId){
				caller = $("#"+callerId);
				caller.length && caller.parents(".ccay-popup").removeClass("ccay-popup-lock");
			}
			//修复带时区的日期控件点击滚动条上面的日期控件消失
			if(popuper.attr("id") == "ccay_calendar_div" && popuper.hasClass("ccay-popup-lock")){
				return ;
			}
			popuper.hide().removeData('_open').removeData('_callInput');
			return true;
		}
		else if(!popuper.data('_open'))
		{	
			var target = popuper.data('_callInput');
			//Ccay.Core.log("closefocus");
			target && !target.attr('disabled') && target.focus();
		}
	}
	//重写Jquery Remove方法，触发dom的销毁事件
	$.fn.__remove = $.fn.remove;
	$.fn.remove = function(){
		if(this.length)
		{
			this.find('[_des]').trigger("elemDestory");
			this.attr("_des") && this.trigger("elemDestory");
		}
		return this.__remove.apply(this,arguments);
	}
	$.fn.__empty = $.fn.empty;
	$.fn.empty = function(){
		if(this.length)
		{
			this.find('[_des]').trigger("elemDestory");
			this.attr("_des") && this.trigger("elemDestory");
		}
		return this.__empty.apply(this,arguments);
	}
	$.fn.__html = $.fn.html;
	$.fn.html = function(html) {
	   if (html === void 0) {
	      return $(this).__html();
	   }
	   var cssReg = Ccay.Config.HtmlRegular.css,
		   cssUrl = Ccay.Config.HtmlRegular.cssUrl;
	   var me = this;
	   /* 匹配css，url表示外部引入，text表示内嵌 begin */
	   var cssArray = [];
	   if (html && typeof html === "string") {
		   html = html.replace(cssReg, function(m, $1, $2, $3) {
	         if (m) {
	        	m = m.match(cssUrl);
	            if (m && m[2]) {
	            	cssArray.push({
	                	url:m[2]
	                });
	            }else{
	            	$3 && cssArray.push({
	            		text:$3
	            	});
	            }
	            return "";
	         }
	         return m;
	      });
	   }
	   /* 匹配css，url表示外部引入，text表示内嵌 end */
	   var returnHtml = $(this).__html(html);
	   if(cssArray.length){
		   /* 引入样式 begin */
		   $.each(cssArray,function(i, d){
			   if(d.url){
				   var link = document.createElement("link");
				   var appVersion = Ccay.Config.Global.appVersion;
				   //给外部引入的css加上版本号
				   link.setAttribute("href",[d.url,appVersion?"?version="+appVersion:""].join(""));
				   link.setAttribute("rel","stylesheet");
				   link.setAttribute("type","text/css");
				   $(me).get(0).appendChild(link);
			   }else if(d.text){
				   $(me).append(['<style type="text/css">',d.text,'</style>'].join(""));
			   }
		   });
		   /* 引入样式 end */
	   }
	   return returnHtml;
	};
	//扩展绑定dom销毁事件
	$.fn.bindDestory = function(fn){
		this.attr("_des","1").bind("elemDestory",fn);
	}
	
	/**@description 注册弹出Hover的响应事件*/
	Ccay.UI.bindPopupHover = function(popuper,fnIn,fnOut){
		popuper.mouseenter(
			function(){
				var popup = $(this);
//				setTimeout(function(){
					popup.data('_inpop',true);
					fnIn && fnIn(popup);
//				},10);
			}).mouseleave(function(){
				var popup = $(this).data('_inpop',null);
				fnOut && fnOut(popuper);
		});
	}
	/**
	 * @description 检查弹出层的位置，使其自适应地显示在caller的上方或者下方
	 * @param caller {JQDom} 请求对象
	 * @param popuper {JQDom} 弹出层对象
	 * @param container {JQDom} popuper容器对象
	 */
	Ccay.UI.checkPopuperPosition = function(caller,popuper) {
		var win = $(window),
			maxWidth = win.width(),
			maxHeight = win.height(),
			scrollLeft = win.scrollLeft(),
			scrollTop = win.scrollTop(),
			offset = caller.offset(),
			callerHeight = caller.outerHeight(),
			width = popuper.outerWidth(),
			height = popuper.outerHeight(),
			pos = {} ,
			bool = ( popuper.attr("id") == "timeZone_calendar_ddl" && caller.attr("id") == "timeZone_calendar" );
		if(offset.top + height + callerHeight - scrollTop > maxHeight){
			pos.top = offset.top - height;
		}else{
			pos.top = offset.top + callerHeight;
		}
		if(offset.left + width - scrollLeft > maxWidth)
			pos.left = maxWidth - width;
		else
			pos.left = offset.left;
			
		pos.top < scrollTop && (pos.top = offset.top + callerHeight);
		pos.left < scrollLeft && (pos.left = offset.left);
		 
		if(bool){
			//日期控件中的时区选择，left 有偏移。 
			pos.left -= 1;
			//若为时区选择，则加大 z-index ，让其盖住日期控件的弹出层
			$("#timeZone_calendar_ddl").css("z-index","9000");
		}
		popuper.css(pos);
		//return offset;
	};
	
	Ccay.UI.getModalPosition = function(caller){
		var modal = caller.parents('div.ccay-dialog:first');
		if(modal.length)
			return modal.position();
	};
	
	/**@description 延迟事件方法执行，在某段时间内不停触发只会一次执行
	 * @param trigger {JQDom}  触发对象
	 * @param bindEvent {String}  触发事件名称
	 * @param fnDelay {Function}  延迟执行的方法，fnDelay(trigger)
	 * @param delayTime {Number}  延迟时间，默认1s
	 * @param fnCheck {Function}  判断是否执行延迟的判断方法，fnCheck(trigger)
	 */
	Ccay.UI.delayEvent = function(trigger, bindEvent,fnDelay, delayTime,fnCheck) {
	    var timeout = true;
	    trigger.bind(bindEvent, function (e) {
	    	var trigger = $(this);
	    	if(timeout)
	    	{
	    		var result = fnCheck ? fnCheck(e,trigger) : true;
	    		if(result)
	    		{
		            timeout = false;
		            setTimeout(function () {
		                fnDelay.call(trigger,e);
		                timeout = true;
		            }, delayTime || 1000);
	    		}
	    	}
	    });
	};
	Ccay.UI.delayEvent2 = function(trigger, bindEvent,fnDelay, delayTime,fnCheck) {
	    trigger.bind(bindEvent, function (e) {
	    	if(e.keyCode != 16){
		    	var trigger = $(this);
		    	if(e.keyCode == 86 && this.value==trigger.data("prevalue")){
		    		return;
		    	}
		    	trigger.data("prevalue",this.value);
		    	var round=parseInt(Math.random()*1000000);
		    	trigger.data("round",round)
				var result = fnCheck ? fnCheck(e,trigger) : true;
				if(result)
				{
					trigger.data("INPUTING",1);
		            setTimeout(function () {
		            	if(trigger.data("round")==round)
		            		trigger.removeData("INPUTING"),fnDelay.call(trigger,e);
		            }, delayTime || 1000);
				}
	    	}
	    });
	}
	/**设置input的光标位置 
	 * input ：input对象
	 * len	：选择文本长度
	 * isSelect ：是否选中值，可不传，默认false
	 */
	Ccay.UI.setInputFocus = function(input,len,isSelect){
		if(document.activeElement.tagName.toLowerCase() == "input" && document.activeElement!=input[0] && $(document.activeElement).hasClass("ccay-dropdown")){
			return;
		}
		if(input.isVisiable()){
			var maxLen = input.val().length;
			if(maxLen){
				var	ctrl = input[0],
					// len是否传值( != undefined 或 != null)
					flag = Ccay.DataHelper.hasValue(len);
				// len为空时或者大于值的长度时
				if (!flag || maxLen < len) {
					len = maxLen;
				};
				// 非IE
				if (ctrl.setSelectionRange) {
					!flag && setTimeout(function(){input.focus();});
					ctrl.setSelectionRange(len, len);
					// 是否选中
					isSelect && input.select();
				}
				// IE
				else {
					setTimeout(function(){input.focus();});
					var sel = ctrl.createTextRange();
					// 是否选中
					if(isSelect){
						sel.moveStart("character", 0);
						sel.moveEnd("character", len);
					}else{
						sel.moveStart("character", len);
						sel.collapse(true);
					}
					sel.select();
				}
			}else{
				setTimeout(function(){input.focus();});
			}
		}
	}
	Ccay.UI.getInputFocus = function(input,getFocus){
		var pos = 0,ctr = input[0] || input;	
		if(ctr == document.activeElement || getFocus)
		{
			if (document.selection) {// IE Support
//				if (input[0].tagName == "TEXTAREA")
//					$(ctr).focus();
				var sel = document.selection.createRange();
				if(ctr.tagName == 'INPUT'){
					sel.moveStart ('character',-ctr.value.length);
					pos = sel.text.length;
				}
				else
				{
					if(sel.text.length)
					{
						pos = ctr.value.indexOf(sel.text);
					}
					else
					{
						ctr.select();
					　	var allRange = document.selection.createRange();
					　	sel.setEndPoint("StartToStart",allRange);
						pos = sel.text.length;
						sel.collapse(false);
						sel.select();
					}
				}
			}
			else if (ctr.selectionStart || ctr.selectionStart == '0')// Firefox support
				pos = ctr.selectionStart;
		}
		return pos;
	}
	/**@description 文本匹配方法
	 * @param text {String}  匹配的文本
	 * @param matchObj {JQDom}  触发事件名称
	 * @param fn {Function}  匹配返回执行的方法,fn(result,item);
	 * @param split {String}  分割符，多项选择时匹配
	 * @param matchAttr {String}  matchObj的属性匹配，默认使用text匹配
	 * @param fnCheck {Function}  自定义check方法，fnCheck(trigger)
	 * @param isHas {Boolean}  是否是text包含匹配的内容
	 */
	Ccay.UI.matchText = function(text,matchObj,fn,split,matchAttr,fnCheck,isHas) {
		text = (text+'').toLowerCase();
		if(split)	
			text = split + text + split;
			
		$(matchObj).each(function(){
			var item = $(this),matchText = matchAttr ? item.attr(matchAttr) : item.text();
			
			matchText = matchText.toLowerCase();
			if(split)	
				matchText = split + matchText + split;
				
			var result = fnCheck ?  fnCheck(matchText,item) : 
					((matchAttr || isHas) ? text.indexOf(matchText) > -1 : matchText.indexOf(text) > -1);
			
			if(fn(result,item,matchText) === false)
				return false;
		});
	}
	
	
	Ccay.UI.ajax = function(ajaxOp,ui){
		var ajax = $.extend({type:'GET'},ajaxOp)
		
		if(ajax.loading == void 0 && ajax.type == "GET")
			ajax.loading = true;
		
		//get请求记录
		if(ajax.type == "GET" && ui && $(ui).data('_cacheRequest')){
			Ccay.UI.ajax.getLastRequest($(ui),ajax.url,ajax.data)
		}
	
		Ccay.Core.ajax(ajax,ajax.loading == 'ui' ? ui :null);
	}
	
	Ccay.UI.ajax.openCacheRequest = function(ui){
		ui.data('_cacheRequest',1);
	}
	//获取上一次get请求的url
	Ccay.UI.ajax.getLastRequest = function(ui,url,param){
		if(url != void 0)
			return ui.data('_url',url).data('_param',param);
		else{
			var url = ui.data('_url');
			if(url)
				return {url:url,param:ui.data('_param')};
			return null;
		}
	}
	Ccay.UI.ajax.setFnSuccess = function(ajax,fnSuccess,before)
	{
		if(fnSuccess)
		{
			var success = ajax.success;
			ajax.success = function(data){
				before && fnSuccess(data);
				success && success(data);
				before || fnSuccess(data);
			}
		}
		else
		{
			ajax.fnSuccess = ajax.success;
			ajax.success = null;
		}
	//	return ajax;
	}
	Ccay.UI.isKeyDownValue  = function(e,supportEspecial){
		var keyCode = e.keyCode, ret = (keyCode > 47 && keyCode < 106 ) || keyCode == 8 || keyCode == 46 || keyCode ==32 || keyCode == 13;
		if(supportEspecial !== false){ 
			ret = ret || keyCode >= 187 && keyCode <= 191 ||  keyCode >= 219 && keyCode <= 222
		}
		return ret;
	}
	Ccay.UI.getValueText = function(datas,op){
		if(op.sortBy){
			Ccay.DataHelper.sort(op.sortBy,"asc",datas);
		}
		var value ='',text='';
		if($.isArray(datas))
		{
			var arrText = new Array(),arrValue = new Array();
			for(var i=0,row=datas[0];row;i++,row=datas[i])
			{
				arrValue.push(row[op.valueField]);
				arrText.push(row[op.displayField]);
			}
			value = arrValue.join(op.valueSplit);
			text = arrText.join(op.multiSplit);
		}
		else
		{
			value =datas[op.valueField];
			text=datas[op.displayField];
		} 
		return {value:value,text:text};
	},
	/*****************************************  UI Manager对象 *********************************/
	Ccay.UI._manager = {
	};
	
	Ccay.UI.Manager = function(){};
	
	Ccay.UI.Manager.prototype = {
		setValue:function(value){
			if(this.ctr.length > 0){
				var tagName = this.ctr[0].tagName;
				if(tagName == "INPUT" || tagName == "SELECT" || tagName == "TEXTAREA"){
					var type = this.ctr.attr('type');
					if(type == "checkbox" || type == 'radio')
						value ? this.ctr.attr('checked','checked') : this.ctr.removeAttr('checked');
					else
						this.ctr.val(value);
				}else{
					this.ctr.text(value);
				}
			}
			return this;
		},
		getValue:function(){
			if(this.ctr.length > 0){
				var value,tagName = this.ctr[0].tagName;
				if(tagName == "INPUT" || tagName == "SELECT" || tagName == "TEXTAREA")
				{
					var type = this.ctr.attr('type');
					if(type == "checkbox" || type == 'radio')
						return this.ctr.attr('checked') ? true : false;
					else
					{
						value = this.ctr.getValue();
						return value != null ? value + '' : "";
					}
				}else{
					//return this.ctr.text(value);
					return this.ctr.text();
				}
			}
			return "";
		},
		disabled:function(enable){
			if(enable)
				this.ctr.removeAttr('disabled');
	    	else
	    		this.ctr.attr('disabled', 'disabled');
	    	return this;
		},
		hide:function(visiable){
			visiable ? this.ctr.show() : this.ctr.hide();
			return this;
		},
		readonly:function(enable){
			if(enable)
				this.ctr.removeAttr('readonly');
	    	else
	    		this.ctr.attr('readonly', 'readonly');
	    	return this;
		}
	};
	Ccay.UI._baseManager = new Ccay.UI.Manager();
	
	Ccay.UI.regManager = function(name,fn){
		Ccay.UI._manager[name] = $.isFunction(fn) ? fn : $.extend(new Ccay.UI.Manager(),fn);
	};
	$.fn.managerReg = function(name,replace){
		if( replace ){
			this.data('ui-manager',name);
		} else {
			//若为这3者标签之一，返回所在位置，否则为-1
			var isThisNodeName = $.inArray(this[0].nodeName, ["INPUT","SELECT","TEXTAREA"]);
			if( isThisNodeName == -1 && !this.data('ui-manager')){
				this.data('ui-manager',name);
			}
		};
		return this;
	};
	$.fn.manager = function(name){
		if(!name)
			name = this.data('ui-manager');
		var manager;
		if(name)
			manager = Ccay.UI._manager[name];
		
		if(!manager)
			manager = Ccay.UI._baseManager;
		
		if($.isFunction(manager))
			return manager(this);
		else{
			manager.ctr = this;
			return manager;
		}
	};
	//控件基类
	var control = $.IObject({
		init:function(dom,op){
			this.dom = dom;
			if(op)
				this._baseInit(op);
			else
		    	this.op = dom.data(this.ctrType + "_op");
		    this.id = dom.id();
		},
		_baseInit:function(op){
			this.op = op;
			this.dom.data(this.ctrType + "_op",op);
			this._manager && this.dom.managerReg(this.ctrType);
		}
	});
	//控件对象
	$.IControl = function(type,prop,isManager){
		isManager || isManager !== false && (isManager = true);
		prop.ctrType = type;
		prop._manager = isManager;
		var ctr = $.IObject(prop,control);
		isManager && Ccay.UI.regManager(type,function(dom){
			return new ctr(dom);
		});
		return ctr;
	}
	//获取标签json属性
	$.fn.getConfig=function(name){
		name || (name = "conf");
		var conf = this.metadata({type:"",name:name,single:name});
	 	return $.isEmptyObject(conf) ? null : conf; 
	}
	
	Ccay.UI.HtmlHelper = {
		getConf:function(dom,name,json){
			return json ? dom.getConfig(name) : dom.attr(name);
		},
		_getAttr:function(dom,attr,remove){
			var name,isJson, tag = attr.substr(0,1);
			if(tag == '#')
			{
				name = attr.substring(1);
				isJson = true;
			}
			else
			{
				name = attr;
			}
			var conf = this.getConf(dom,name,isJson);
			if(conf)
			{
				remove && dom.removeAttr(name);
				isJson && (conf._json = true);
			}
			return {name : name, attr : conf};
		},
		getAttr:function(dom,attrs,remove,op){
			if($.type(attrs) == 'array')
			{
				var conf = op || {};
				for(var i = 0,attr;attr = attrs[i];i++){
					if(attr)
					{
						var value = this._getAttr(dom,attr,remove);
						value.attr && (conf[value.name] = value.attr);
					}
				}
				return conf;
			}
			else
			{
				var value = this._getAttr(dom,attr,remove);
				if(op){
					value.attr && (op[value.name] = value.attr);
					return op;
				}
				else
					return value.attr;
			}
		},
		toAttrStr:function(attrs){
			var arr = [];
			$.each(attrs,function(name,attr){
				arr.push(" ",name,'="',attr,'"');
			})
			return arr.join('');
		},
		formatAttr:function(op){
			$.each(op,function(name,conf){
				conf._json && (delete conf._json) && (op[name] = Ccay.UI.HtmlHelper.toAttrStr(conf));
			})
		}
	};
})();
